//性别
function setLabels(el, element, value) {
    if($(el).hasClass('checked')) {
        return
    } else {
        $("#" + element).val(value)
        $(el).addClass('checked').siblings().removeClass('checked')
    }

}

// 额度指针旋转开始
(function() {
    var i = 0,
        times = 0,
        deg = -69,
        timer = null;
    timer = setInterval(function() {
        i++;
        deg += 7;
        var vbl = i * 2 / 140;
        var mo_num = parseInt((200000 - 0) * vbl);

        if(deg >= 65) {
            $(".pointer").css({
                transform: "rotate(65deg)"

            });
            $(".pointer .ball").css({
                top: "-0.28rem"
            })
            $(".eduNum").text(200000);
            $("body").css({
                "overflow-x": "hidden"
            })
            clearInterval(timer);
            return;
        }
        $(".pointer").css({
            transform: "rotate(" + deg + "deg)"
        })

        $(".eduNum").text(mo_num)
    }, 80)
})();



//判断数据
function checkParameterone() {

    if($("#el_edu").val() == "") {
        alert("请选择期待借款金额！");
        return false;
    }

    if(isNull($("#show_contact").text())) {
        alert("请选择城市！");
        return false
    }
    if(isNull($("#income").val())) {
        alert("请选择您的月收入");
        $("#income").focus();
        return false
    }
    if(isNull($("#paytype").val())) {
        alert("请选择发薪方式");
        return false;
    }

    
    if(isNull($("#profession").val())) {
        alert("请选择您的职业");
        $("#profession").focus();
        return false
    }

    if($("#socialSecurity").val() == '') {
        alert("请选择社保情况");
        return false
    }

    if($("#creditSituation").val() == '') {
        alert("请选择信用卡情况");
        return false
    }

    if($("#housingFund").val() == '') {
        alert("请选泽公积金情况");
        return false
    }
    if($("#loanRecord").val() == '') {
        alert("请选择贷款记录");
        return false
    }
    if($("#auditBy").val() == '') {
        alert("请选择微粒贷情况");
        return false
    }

    if($("#house").val() == '') {
        alert("请选择您的名下房产情况");
        return false
    }
    if($("#car").val() == '') {
        alert("请选择您的名下汽车情况");
        return false
    }
    if($("#baodan").val() == '') {
        alert("请选择您的保单信息");
        return false
    }


    if($("#acceptsafety").val() == 0) {
        alert(" 请同意用户协议再提交！");
        return false;
    }
    var mobile = $("#mobile2").val(),
        code = $("#textcode").val();
    gsc.verifyCode(mobile, code, smsCodeCallback);

}

$(function() {

    $(".close,.sure").click(function() {
        $(".dk_popupContainer").fadeOut()
    });
    $("#safe").click(function() {
        $("#acceptsafety").val(1 - eval($("#acceptsafety").val()));
    });

    var checkbox0 = new checkCard({
        target: "#el_edu",
        valuetarget: "#edu",
        data: [{
                text: "1000",
                value: 1000
            },
            {
                text: "2000",
                value: 2000
            },
            {
                text: "3000",
                value: 3000
            },
            {
                text: "4000",
                value: 4000
            },
            {
                text: "5000",
                value: 5000
            },
            {
                text: "6000",
                value: 6000
            },
            {
                text: "更多",
                value: "110"
            }

        ]
    })

    var checkbox = new checkCard({
        target: "#el_income",
        valuetarget: "#income",
        data: [{
                text: "4000以下",
                value: 4000
            },
            {
                text: "4000-6000",
                value: 6000
            },
            {
                text: "6000-1万",
                value: 10000
            },
            {
                text: "1万-2万",
                value: 20000
            },
            {
                text: "2万以上",
                value: 30000
            }

        ]
    })
    var checkbox2 = new checkCard({
        target: "#el_paytype",
        valuetarget: "#paytype",
        data: [{
                text: "银行转账",
                value: 1
            },
            {
                text: "现金发放",
                value: 2
            },
        ]
    })
    var checkbox3 = new checkCard({
        target: "#el_worklong",
        valuetarget: "#worklong",
        data: [{
                text: "6个月内",
                value: 6
            },
            {
                text: "12个月内",
                value: 12
            },
            {
                text: "一年以上",
                value: 24
            },
        ]
    })

    var checkbox4 = new checkCard({
        target: "#el_profession",
        valuetarget: "#profession",
        data: [{
                text: "白领",
                value: 0
            },
            {
                text: "公务员",
                value: 2
            },
            {
                text: "私企业主",
                value: 1
            },
            {
                text: "自由职业者",
                value: 3
            },
        ],
        callbackf: function() {
            $(".botMsg").show();
        }
    })
    var checkbox5 = new checkCard({
        target: "#el_house",
        valuetarget: "#house",
        data: [{
                text: "无房",
                value: 1
            },
            {
                text: "有房贷",
                value: 2
            },
            {
                text: "有房无贷",
                value: 3
            },
        ],

    })
    var checkbox6 = new checkCard({
        target: "#el_auditBy",
        valuetarget: "#auditBy",
        data: [{
                text: "无微粒贷",
                value: 1
            },
            {
                text: "未还完",
                value: 2
            },
            {
                text: "已还完",
                value: 3
            },
        ],

    })
    var checkbox7 = new checkCard({
        target: "#el_car",
        valuetarget: "#car",
        data: [{
                text: "无车",
                value: 1
            },
            {
                text: "有车贷",
                value: 2
            },
            {
                text: "有车无贷",
                value: 3
            },
        ],

    })
    var checkbox8 = new checkCard({
        target: "#el_baodan",
        valuetarget: "#baodan",
        data: [{
                text: "无保单",
                value: 0
            },
            {
                text: "额度2400以上",
                value: 2
            },
            {
                text: "额度2400以下",
                value: 1
            },
        ],

    });


    $('.sex-box label').on('click',function(){
        if($(this).hasClass('btn-checked')){
            
        }else{
            $(this).siblings('label').removeClass('btn-checked');
            $(this).siblings('label').find('input').removeAttr('checked');
            $(this).addClass('btn-checked');
            $(this).find('input').attr('checked');
        }
    });

    // 城市插件调用开始
    var area2 = new LArea();
    area2.init({
        'trigger': '#show_contact',
        'keys': {
            id: 'value',
            name: 'text'
        },
        'type': 2,
        'data': [provs_data, citys_data],
        callback: function(p, c) {
            $("#province").val(p);
            // console.log(p, c)
            if(c == "" || c == "市辖区" || c == "县") {
                $("#show_contact").text(p);
                return;
            }
            $("#show_contact").text(c);
        }
    });


})





